package cn.zifangsky.jvm.part1.structure;

/**
 * 递归调用的原理
 *
 * @author zifangsky
 * @date 2020/7/2
 * @since 1.0.0
 */
public class Factorial {
    public static void main(String[] args) {
        int ret = factorial(4);

        System.out.println(ret);
    }

    public static int factorial(int n) {
        if (n == 0) {
            return 1;
        } else {
            return n * factorial(n - 1);
        }
    }
}
